package com.hyt.it.ogt.controller.ykcj.exam;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.annotation.Log;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.common.core.page.TableDataInfo;
import com.hyt.it.ogt.ykcj.common.enums.BusinessType;
import com.hyt.it.ogt.ykcj.common.utils.poi.ExcelUtil;
import com.hyt.it.ogt.ykcj.domain.exam.ExamPostScoreLineSetting;
import com.hyt.it.ogt.ykcj.domain.vo.ExamPostScoreLineSettingVo;
import com.hyt.it.ogt.ykcj.service.exam.IExamPostScoreLineSettingService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;

/**
 * 招考职位分数线设置Controller
 * 
 * @author admin
 * @date 2021-09-09
 */
@Api(tags = "exam.4.招考职位分数线设置", value = "招考分数线设置请求接口")
@ApiSort(value = 104)
@RestController
@RequestMapping("/exam/postScoreLineSetting")
public class ExamPostScoreLineSettingController extends BaseController
{
    @Autowired
    private IExamPostScoreLineSettingService examPostScoreLineSettingService;

    /**
     * 查询招考职位分数线设置列表
     */
    @ApiOperation("查询招考职位分数线设置列表")
    @GetMapping("/list")
    public TableDataInfo list(ExamPostScoreLineSetting examPostScoreLineSetting)
    {
        startPage();
        List<ExamPostScoreLineSetting> list = examPostScoreLineSettingService.selectExamPostScoreLineSettingList(examPostScoreLineSetting);
        return getDataTable(list);
    }

    /**
     * 导出招考职位分数线设置列表
     */
    @ApiOperation("导出招考职位分数线设置列表")
    @Log(title = "招考职位分数线设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ExamPostScoreLineSetting examPostScoreLineSetting)
    {
        List<ExamPostScoreLineSetting> list = examPostScoreLineSettingService.selectExamPostScoreLineSettingList(examPostScoreLineSetting);
        ExcelUtil<ExamPostScoreLineSetting> util = new ExcelUtil<ExamPostScoreLineSetting>(ExamPostScoreLineSetting.class);
        return util.exportExcel(list, "招考职位分数线设置数据");
    }

    /**
     * 获取招考职位分数线设置详细信息
     */
    @ApiOperation("获取招考职位分数线设置详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(examPostScoreLineSettingService.selectExamPostScoreLineSettingById(id));
    }

    /**
     * 新增招考职位分数线设置
     */
    @ApiOperation("新增招考职位分数线设置")
    @Log(title = "招考职位分数线设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamPostScoreLineSetting examPostScoreLineSetting)
    {
        return toAjax(examPostScoreLineSettingService.insertExamPostScoreLineSetting(examPostScoreLineSetting));
    }

    /**
     * 修改招考职位分数线设置
     */
    @ApiOperation("修改招考职位分数线设置")
    @Log(title = "招考职位分数线设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamPostScoreLineSetting examPostScoreLineSetting)
    {
        return toAjax(examPostScoreLineSettingService.updateExamPostScoreLineSetting(examPostScoreLineSetting));
    }

    /**
     * 删除招考职位分数线设置
     */
    @ApiOperation("删除招考职位分数线设置")
    @Log(title = "招考职位分数线设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(examPostScoreLineSettingService.deleteExamPostScoreLineSettingByIds(ids));
    }

    /**
     * 获取职位分数线设置选项下拉
     * @param examId 考试ID
     * @param dictType 字典类型（category:类别；position_category:职位类别；position_tier:职位分布；join_exam_tier:机构层级；exam_organ_nature:机构性质）
     * @return 结果
     */
    @ApiOperation("获取职位分数线设置选项下拉")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "examId", value = "考试ID", dataType = "String", required = true),
            @ApiImplicitParam(name = "dictType", value = "字典类型（category:类别；position_category:职位类别；position_tier:职位分布；join_exam_tier:机构层级；exam_organ_nature:机构性质）", dataType = "String")
    })
    @GetMapping("/getPostScoreLineSettingOption")
    public AjaxResult getPostScoreLineSettingOption(String examId, String dictType) {
        return AjaxResult.success(examPostScoreLineSettingService.getPostScoreLineSettingOption(examId, dictType));
    }

    /**
     * 获取职位数量
     * @param examPostScoreLineSetting 招考职位分数线设置
     * @return 职位数量
     */
    @ApiOperation("获取职位数量")
    @GetMapping("/getPostNumber")
    public AjaxResult getPostNumber(ExamPostScoreLineSetting examPostScoreLineSetting) {
        return AjaxResult.success(examPostScoreLineSettingService.getPostNumber(examPostScoreLineSetting));
    }

    /**
     * 保存招考职位分数线设置
     */
    @ApiOperation("保存招考职位分数线设置")
    @Log(title = "招考职位分数线设置", businessType = BusinessType.INSERT)
    @PostMapping("/saveExamPostScoreLineSetting")
    public AjaxResult saveExamPostScoreLineSetting(@RequestBody List<ExamPostScoreLineSettingVo> listVo) {
        return AjaxResult.success(examPostScoreLineSettingService.insertBatchExamPostScoreLineSetting(listVo));
    }

    /**
     * 获取招考职位分数线设置列表
     */
    @ApiOperation("获取招考职位分数线设置列表")
    @GetMapping("/getList/{examId}")
    public AjaxResult getList(@PathVariable String examId) {
        return AjaxResult.success(examPostScoreLineSettingService.getList(examId));
    }
}

